package org.geekbang.bigdata.rpc;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;
import org.geekbang.bigdata.rpc.protocol.MyProtocol;

import java.io.IOException;
import java.net.InetSocketAddress;

public class Client {
    public static void main(String[] args) {
        try {
            InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 12345);
            MyProtocol proxy = RPC.getProxy(MyProtocol.class, MyProtocol.versionID, addr, new Configuration());

            long[] ids = { 20210000000000L, 20210123456789L, 20210735010106L};
            String name = proxy.findName(ids[0]);
            System.out.println(ids[0] + ": " + name);
            name = proxy.findName(ids[1]);
            System.out.println(ids[1] + ": " + name);
            name = proxy.findName(ids[2]);
            System.out.println(ids[2] + ": " + name);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
